package com.zhu.cloudspring.service;

import com.zhu.cloudspring.config.RabbitMQConfig;
import com.zhu.cloudspring.entity.Order;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class RabbitMQConsumer {

    @Autowired
    private SmsService smsService;

    @RabbitListener(queues = RabbitMQConfig.ORDER_QUEUE_NAME)
    public void receiveOrderMessage(Object[] message) {
        Order order = (Order) message[0];
        String consignee = (String) message[1];
        smsService.sendSms(order, consignee);
    }
}
